package com.yx.filesystem.storage;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import org.json.JSONObject;

public class FileGetHandler extends SocketHandler {

	public FileGetHandler() {
		// TODO 自动生成的构造函数存根
	}

	@Override
	public boolean handler(BufferedInputStream socketInput,
			BufferedOutputStream socketOutput, Transport transport)
			throws Exception {
		Archive fileDoc = new Archive(transport.getMessage());
		JSONObject jsonContent=new JSONObject();
		jsonContent.put("FILE_LENGTH", fileDoc.length());
		Transport returnNioCmd = new Transport(null, true, fileDoc.getName(),
				jsonContent);		
		returnNioCmd.write(socketOutput);
		fileDoc.read(socketOutput);
		return true;
	}

}
